package cn.achao.csr.base.utils;

import cn.achao.csr.base.exception.BusinessException;

/**
 * 抛异常工具类
 * @Author: achao
 **/
public class ThrowUtils {

    /**
     * 抛出最大异常
     * @param runtimeException
     */
    public static void throwIf(RuntimeException runtimeException) {
        throw runtimeException;
    }

    /**
     * 条件成立则抛异常
     *
     * @param condition
     * @param runtimeException
     */
    public static void throwIf(boolean condition, RuntimeException runtimeException) {
        if (condition) {
            throw runtimeException;
        }
    }

    /**
     * 条件成立则抛异常
     * @param condition
     * @param businessException
     */
    public static void throwIf(boolean condition, BusinessException businessException) {
        if (condition) {
            throw businessException;
        }
    }

}
